<?php

/*
 * @author Ebrain Cedeno <ebraincedeno@gmail.com>
 */

class TDialog extends TWidget{
    
    public $Title = "&nbsp;";
    public $Modal = true;
    public $AutoOpen = 'true';
    
    protected $html;
    
    public function __construct($name = __CLASS__) {
        parent::__construct($name);
        $this->Width = 800;
        $this->Height = 600;
    }
    
    public function add($value){
        $this->html = $value;
    }
    
    public function show(){
        
        if ($this->Visible == true){
        
            if (!array_key_exists('style', $this->OptionsAditional)){
                $this->OptionsAditional['style'] = array('width:'.$this->Width.'px','height:'.$this->Height.'px');
            }
            else{
                $this->OptionsAditional['style'][] = 'width:'.$this->Width.'px';
                $this->OptionsAditional['style'][] = 'height:'.$this->Height.'px';
            }    

            return '<script>
                        var $'.$this->Id.'
                        $(function() {
                            $'.$this->Id.' = $( "#'.$this->Id.'" ).dialog({autoOpen:'.$this->AutoOpen.',modal:'.$this->Modal.',width:'.$this->Width.',height:'.$this->Height.'});
                        });
                    </script>'."\n".'
                        <div id="'.$this->Id.'" title="'.$this->Title.'" '.$this->getOptionsAditional().'>'.$this->html.'</div>';
        }
    }
    
}

?>
